<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">
        <h:form>

            <p:panel>
                <p:panel >
                    <f:facet name="header">
                        <p:outputLabel value="Admitted Patients"/>
                        <p:commandButton ajax="false" value="Cancel" action="#{dischargeController.cancel}" style="float: right;"/>
                    </f:facet>
                    
                    <h:panelGrid id="gpSelectText" columns="4" >
                        <p:outputLabel value="Type Patinet Name or BHT"/>
                        <p:autoComplete converter="dis" widgetVar="aPt" id="acPt" forceSelection="true" 
                                        value="#{dischargeController.current}"
                                        completeMethod="#{dischargeController.completePatient}" 
                                        var="myItem" itemValue="#{myItem}" 
                                        itemLabel="#{myItem.bhtNo}#{myItem.patient.person.nameWithTitle}" 
                                        size="30"  style="width: 400px;">
                            <f:ajax execute="acPt" render="gpDetail" event="itemSelect" />
                        </p:autoComplete>   
                        <p:commandButton ajax="false" value="Clear" action="#{dischargeController.makeNull}"/>

                    </h:panelGrid>
                </p:panel>

                <p:panel id="gpDetail">
                    <p:panel>
                        <h:panelGrid columns="2" style="min-width: 100%;">
                            <p:panel header="Patient Detail" >
                                <h:panelGrid columns="2">
                                    <p:outputLabel  value="Name" />
                                    <p:outputLabel value="#{dischargeController.current.patient.person.nameWithTitle}"/>
                                    <p:outputLabel value="NIC" />
                                    <p:outputLabel  value="#{dischargeController.current.patient.person.nic}"  />
                                    <p:outputLabel value="Age"/>
                                    <p:outputLabel value="#{dischargeController.current.patient.age}"/>
                                    <p:outputLabel value="Address" />
                                    <p:outputLabel  value="#{dischargeController.current.patient.person.address}" />
                                    <p:outputLabel value="Phone No" />
                                    <p:outputLabel  value="#{dischargeController.current.patient.person.phone}"  />
                                </h:panelGrid>
                            </p:panel>

                            <p:panel header="Gardian Detail">
                                <h:panelGrid columns="2">
                                    <p:outputLabel  value="Name" />
                                    <p:outputLabel value="#{dischargeController.current.guardian.name}"  />
                                    <p:outputLabel value="Address" />
                                    <p:outputLabel  value="#{dischargeController.current.guardian.address}"  />
                                    <p:outputLabel value="Phone No" />
                                    <p:outputLabel  value="#{dischargeController.current.guardian.phone}"  />
                                </h:panelGrid>
                            </p:panel>
                        </h:panelGrid>

                        <h:panelGrid columns="2" style="min-width: 100%;">
                            <p:panel header="Admission Detail">
                                <h:panelGrid columns="2">
                                    <p:outputLabel value="BHT No"/>
                                    <p:outputLabel value="#{dischargeController.current.bhtNo}" />
                                    <p:outputLabel value="Admitted At"/>
                                    <p:outputLabel value="#{dischargeController.current.dateOfAdmission}" />
                                    <p:outputLabel value="Payment Method"/>
                                    <p:outputLabel value="#{dischargeController.current.paymentMethod}" />
                                </h:panelGrid>
                            </p:panel>
                            <p:panel header="Room Detail">
                                <p:dataTable value="#{dischargeController.patientRoom}" var="rm">
                                    <p:column headerText="Room Name">
                                        #{rm.roomFacilityCharge.name}
                                    </p:column>                                  
                                </p:dataTable>
                            </p:panel>
                        </h:panelGrid>

                    </p:panel>
                </p:panel>
            </p:panel>
        </h:form>
    </ui:define>

</ui:composition>
